<?php

$dsn = "mysql:host=localhost;dbname=cnrt";
$user = 'ragnarok';
$pass = 'clave';
try {
  $conn = new PDO($dsn, $user, $pass);
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $q = "INSERT INTO personas (nombre,apellido,email) ";
  $q .= " VALUES (";
  $q .= "'" . $_POST['nombre'] . "',";
  $q .= "'" . $_POST['apellido'] . "',";
  $q .= "'" . $_POST['email'] . "'";
  $q .= ")";

  $conn->exec($q);
  echo "Sus datos se guardaron correctamente";
} catch (Exception $e) {
  echo "Ocurrio un error: " . $e->getMessage();
}
?>
